package com.sans.collection;

import org.junit.Test;

import java.util.HashSet;

/**
 * @author Sans
 */
public class SetTest {
    @Test
    public void hashSet() {
        HashSet<String> hashSet = new HashSet<>();
        System.out.println(hashSet.isEmpty() ? "为空" : "不为空");
        System.out.println("hashSet的容量:" + hashSet.size());
        System.out.println(hashSet.hashCode());
        hashSet.add("a");
        hashSet.add("b");
        hashSet.add("c");
        System.out.println(hashSet.hashCode());
        hashSet.remove("c");
        System.out.println(hashSet.hashCode());
        hashSet.add("b");
        System.out.println(hashSet.hashCode());

        for (String e : hashSet) {
            System.out.println(e);
        }
    }
}
